import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
}


export default new Router({
  routes: [
    {
      path: '/',
      redirect: '/login',
      component: () => import('../components/index/index'),
      children: [
        {
          path: 'user',
          component: () => import('../components/user/user')
        },
        {
          path: 'dict',
          component: () => import('../components/dict/dict')
        },
        {
          path: 'book',
          component: () => import('../components/book/book')
        },
        {
          path: '/index',
          component: () => import('../components/index/first')
        },
        {
          path: 'manager',
          component: () => import('../components/manager/manager')
        },
        {
          path: 'userAdvice',
          component: () => import('../components/system/userAdvice')
        },
        {
          path: 'fileType',
          component: () => import('../components/fileType/fileType')
        },
        {
          path: 'self',
          component: () => import('../components/user/self')
        },
        {
          path: 'message',
          component: () => import('../components/system/message')
        }
      ]
    },
    {
      path: '/login',
      component: () => import('../components/login/login')
    }
  ]
})
